﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.Model;
using Automobile.service.BLL;
using System.Data;

namespace Automobile.service.UI
{
    public partial class UpdateSupplier : System.Web.UI.Page
    {
        SupplierBll bll = new SupplierBll();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["fid"] != null)
                {
                    LoadData();
                }
            }
        }

        private void LoadData()
        {
            this.TextBox5.Text = Request.QueryString["fid"].ToString();

            DataTable dt = bll.GetSupplier(this.TextBox5.Text);
            if (dt != null)
            {
                this.TextBox1.Text = dt.Rows[0][1].ToString();
                this.TextBox2.Text = dt.Rows[0][2].ToString();
                this.TextBox3.Text = dt.Rows[0][3].ToString();
                this.TextBox4.Text = dt.Rows[0][4].ToString();
            }
        }
        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("Supplier.aspx");  //页面跳转
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SupplierModel model = new SupplierModel();
            model.Supplier_Id = Convert.ToInt32(this.TextBox5.Text);
            model.Supplier_Name = TextBox1.Text;
            model.Supplier_People = TextBox2.Text;
            model.Supplier_Phone = TextBox3.Text;
            model.Supplier_Addr = TextBox4.Text;
            if (bll.UpdateSupplierModel(model) > 0)
            {
                Response.Write("<script>alert('供应商信息修改成功!');location.href='Supplier.aspx';</script>");
            }
        }


    }
}